package gui;

import gamemngr.HelpMenu;

import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.dnd.DND;
import org.eclipse.swt.dnd.DragSource;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Dialog;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.TabFolder;
import org.eclipse.swt.widgets.TabItem;
import org.eclipse.swt.widgets.Text;
import com.swtdesigner.SWTResourceManager;

public class HelpDialog extends Dialog {

	private StyledText HowToPlayText;
	private StyledText MapText;
	private StyledText AttackText;
	private StyledText SoldiersText;
	private StyledText MenuText;
	private StyledText IntroductionText;
	protected Object result;
	protected Shell shell;

	/**
	 * Create the dialog
	 * @param parent
	 * @param style
	 */
	public HelpDialog(Shell parent, int style) {
		super(parent, style);
	}

	/**
	 * Create the dialog
	 * @param parent
	 */
	public HelpDialog(Shell parent) {
		this(parent, SWT.NONE);
	}

	/**
	 * Open the dialog
	 * @return the result
	 */
	public Object open() {
		createContents();
		shell.open();
		shell.layout();
		Display display = getParent().getDisplay();
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch())
				display.sleep();
		}
		return result;
	}

	/**
	 * Create contents of the dialog
	 */
	protected void createContents() {
		shell = new Shell(getParent(), SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);
		shell.setLayout(new FillLayout());
		shell.setLocation(RiskGUI.getNewPosition(getParent()));
		shell.setSize(562, 398);
		shell.setText("Help");

		final TabFolder tabFolder = new TabFolder(shell, SWT.NONE);

		final TabItem IntroductionTabItem = new TabItem(tabFolder, SWT.NONE);
		IntroductionTabItem.setText("Introduction");

		final TabItem HowToPlayTabItem = new TabItem(tabFolder, SWT.NONE);

		HowToPlayText = new StyledText(tabFolder, SWT.WRAP | SWT.V_SCROLL | SWT.READ_ONLY | SWT.BORDER);
		HowToPlayText.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WIDGET_LIGHT_SHADOW));
		HowToPlayTabItem.setControl(HowToPlayText);
		HowToPlayTabItem.setText("How to play");
		
		IntroductionText = new StyledText(tabFolder, SWT.WRAP | SWT.V_SCROLL | SWT.READ_ONLY | SWT.BORDER);
		IntroductionText.setEnabled(false);
		IntroductionText.setEditable(false);
		IntroductionText.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WIDGET_LIGHT_SHADOW));
		IntroductionTabItem.setControl(IntroductionText);

		final TabItem menuTabItem = new TabItem(tabFolder, SWT.NONE);
		menuTabItem.setText("Menu");

		MenuText = new StyledText(tabFolder, SWT.WRAP | SWT.V_SCROLL | SWT.READ_ONLY | SWT.BORDER);
		MenuText.setEditable(false);
		MenuText.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WIDGET_LIGHT_SHADOW));
		menuTabItem.setControl(MenuText);

		final TabItem soldiersTabItem = new TabItem(tabFolder, SWT.NONE);
		soldiersTabItem.setText("Soldiers");

		SoldiersText = new StyledText(tabFolder, SWT.WRAP | SWT.V_SCROLL | SWT.READ_ONLY | SWT.BORDER);
		SoldiersText.setEditable(false);
		SoldiersText.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WIDGET_LIGHT_SHADOW));
		soldiersTabItem.setControl(SoldiersText);

		final TabItem attackTabItem = new TabItem(tabFolder, SWT.NONE);
		attackTabItem.setText("Attack");

		AttackText = new StyledText(tabFolder, SWT.WRAP | SWT.V_SCROLL | SWT.READ_ONLY | SWT.BORDER);
		AttackText.setEditable(false);
		AttackText.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WIDGET_LIGHT_SHADOW));
		attackTabItem.setControl(AttackText);

		final TabItem mapTabItem = new TabItem(tabFolder, SWT.NONE);
		mapTabItem.setText("Map");

		MapText = new StyledText(tabFolder, SWT.WRAP | SWT.V_SCROLL | SWT.READ_ONLY | SWT.BORDER);
		MapText.setEditable(false);
		MapText.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WIDGET_LIGHT_SHADOW));
		mapTabItem.setControl(MapText);
		
		HelpMenu Introduction = new HelpMenu("Introduction.txt");
		IntroductionText.setText(Introduction.toString());
		
		HelpMenu HowToPlay = new HelpMenu("HowToPlay.txt");
		HowToPlayText.setText(HowToPlay.toString());
		
		HelpMenu Menu = new HelpMenu("helpMenu.txt");
		MenuText.setText(Menu.toString());
		
		HelpMenu SoldiersRules = new HelpMenu("helpSoldiers.txt");
		SoldiersText.setText(SoldiersRules.toString());
		
		HelpMenu AttackRules = new HelpMenu("helpAttack.txt");
		AttackText.setText(AttackRules.toString());

		HelpMenu MapMenu = new HelpMenu("helpMap.txt");
		MapText.setText(MapMenu.toString());
		//
	}

}
